package org.budo.beetl.resource.util;

import java.io.InputStream;
import java.io.Reader;

import org.beetl.core.Resource;
import org.budo.beetl.resource.BeetlResource;
import org.budo.support.lang.util.IoUtil;

/**
 * @author lmw
 */
public class BeetlResourceUtil {
    public static InputStream inputStream(Resource resource) {
        if (resource instanceof BeetlResource) {
            return ((BeetlResource) resource).inputStream();
        }

        Reader reader = resource.openReader();
        return IoUtil.toInputStream(reader);
    }
}